<html>
<head><meta charset="utf-8"><title>Source formatting guidance in Rustc Dev Guide · t-compiler/wg-rustc-dev-guide · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/index.html">t-compiler/wg-rustc-dev-guide</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source.20formatting.20guidance.20in.20Rustc.20Dev.20Guide.html">Source formatting guidance in Rustc Dev Guide</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="190343044"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source%20formatting%20guidance%20in%20Rustc%20Dev%20Guide/near/190343044" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Chris Simpkins <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source.20formatting.20guidance.20in.20Rustc.20Dev.20Guide.html#190343044">(Mar 11 2020 at 23:24)</a>:</h4>
<p>We have <a href="https://rustc-dev-guide.rust-lang.org/conventions.html#how-to-structure-your-pr" target="_blank" title="https://rustc-dev-guide.rust-lang.org/conventions.html#how-to-structure-your-pr">documentation in the Rustc Dev Guide</a> that states the following:</p>
<blockquote>
<p>Only run rustfmt on new content. One day, we might enforce formatting for the rust-lang/rust repo. Meanwhile, we prefer that rustfmt not be run on existing code as that will generate large diffs and will make git blame harder to sift through. However, running rustfmt on new content, e.g. a new file or a largely new part of a file is ok. Small formatting adjustments nearby code you are already changing for other purposes are also ok.</p>
</blockquote>
<p>I reached out to the Rustfmt WG on Discord today and learned that rustfmt nightly has a <code>--file-lines</code> option for explicit source file line range formatting.  It is listed as being unstable with the following help docs:</p>
<div class="codehilite"><pre><span></span><span class="go">If you want to restrict reformatting to specific sets of lines, you can</span>
<span class="go">use the `--file-lines` option. Its argument is a JSON array of objects</span>
<span class="go">with `file` and `range` properties, where `file` is a file name, and</span>
<span class="go">`range` is an array representing a range of lines like `[7,13]`. Ranges</span>
<span class="go">are 1-based and inclusive of both end points. Specifying an empty array</span>
<span class="go">will result in no files being formatted. For example,</span>

<span class="go">rustfmt --file-lines &#39;[</span>
<span class="go">    {&quot;file&quot;:&quot;src/lib.rs&quot;,&quot;range&quot;:[7,13]},</span>
<span class="go">    {&quot;file&quot;:&quot;src/lib.rs&quot;,&quot;range&quot;:[21,29]},</span>
<span class="go">    {&quot;file&quot;:&quot;src/foo.rs&quot;,&quot;range&quot;:[10,11]},</span>
<span class="go">    {&quot;file&quot;:&quot;src/foo.rs&quot;,&quot;range&quot;:[15,15]}]&#39;</span>

<span class="go">would format lines `7-13` and `21-29` of `src/lib.rs`, and lines `10-11`,</span>
<span class="go">and `15` of `src/foo.rs`. No other files would be formatted, even if they</span>
<span class="go">are included as out of line modules from `src/lib.rs`.</span>
</pre></div>


<p>Thoughts about our current Rustc Dev Guide fmt documentation for contributors and whether this unstable, nightly only rustfmt approach should be mentioned?  Anyone have experience with it?</p>



<a name="190350369"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source%20formatting%20guidance%20in%20Rustc%20Dev%20Guide/near/190350369" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source.20formatting.20guidance.20in.20Rustc.20Dev.20Guide.html#190350369">(Mar 12 2020 at 01:48)</a>:</h4>
<p>oh my, that is quite outdated</p>



<a name="190350373"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source%20formatting%20guidance%20in%20Rustc%20Dev%20Guide/near/190350373" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source.20formatting.20guidance.20in.20Rustc.20Dev.20Guide.html#190350373">(Mar 12 2020 at 01:48)</a>:</h4>
<p>The correct thing to do is run <code>./x.py fmt</code></p>



<a name="190350390"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source%20formatting%20guidance%20in%20Rustc%20Dev%20Guide/near/190350390" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source.20formatting.20guidance.20in.20Rustc.20Dev.20Guide.html#190350390">(Mar 12 2020 at 01:49)</a>:</h4>
<p>And the CI does enforce (via tidy) that ./x.py fmt --check passes</p>



<a name="190350632"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source%20formatting%20guidance%20in%20Rustc%20Dev%20Guide/near/190350632" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Chris Simpkins <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source.20formatting.20guidance.20in.20Rustc.20Dev.20Guide.html#190350632">(Mar 12 2020 at 01:55)</a>:</h4>
<p>Should the recommendation be <code>./x.py fmt [file you are working on]</code> or without an argument?</p>



<a name="190351002"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source%20formatting%20guidance%20in%20Rustc%20Dev%20Guide/near/190351002" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source.20formatting.20guidance.20in.20Rustc.20Dev.20Guide.html#190351002">(Mar 12 2020 at 02:05)</a>:</h4>
<p>x.py fmt does not take a file argument</p>



<a name="190351017"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source%20formatting%20guidance%20in%20Rustc%20Dev%20Guide/near/190351017" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source.20formatting.20guidance.20in.20Rustc.20Dev.20Guide.html#190351017">(Mar 12 2020 at 02:05)</a>:</h4>
<p>you should run x.py fmt as-is</p>



<a name="190351022"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source%20formatting%20guidance%20in%20Rustc%20Dev%20Guide/near/190351022" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Chris Simpkins <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source.20formatting.20guidance.20in.20Rustc.20Dev.20Guide.html#190351022">(Mar 12 2020 at 02:05)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116122">simulacrum</span> <a href="#narrow/stream/196385-t-compiler.2Fwg-learning/topic/Source.20formatting.20guidance.20in.20Rustc.20Dev.20Guide/near/190351017" title="#narrow/stream/196385-t-compiler.2Fwg-learning/topic/Source.20formatting.20guidance.20in.20Rustc.20Dev.20Guide/near/190351017">said</a>:</p>
<blockquote>
<p>you should run x.py fmt as-is</p>
</blockquote>
<p>ty!</p>



<a name="190351028"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source%20formatting%20guidance%20in%20Rustc%20Dev%20Guide/near/190351028" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source.20formatting.20guidance.20in.20Rustc.20Dev.20Guide.html#190351028">(Mar 12 2020 at 02:05)</a>:</h4>
<p>I would also (very) strongly recommend setting up rustfmt on save in your editor</p>



<a name="190351079"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source%20formatting%20guidance%20in%20Rustc%20Dev%20Guide/near/190351079" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source.20formatting.20guidance.20in.20Rustc.20Dev.20Guide.html#190351079">(Mar 12 2020 at 02:06)</a>:</h4>
<p>a handy trick is to define a folder-local or project-local or w/e config to point rustfmt at the local downloaded rustfmt binary, e.g., I have <code>let g:rustfmt_command = "/Users/mark/Edit/rust/build/x86_64-apple-darwin/stage0/bin/rustfmt"</code> in my project-specific .vimrc</p>



<a name="190351098"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source%20formatting%20guidance%20in%20Rustc%20Dev%20Guide/near/190351098" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source.20formatting.20guidance.20in.20Rustc.20Dev.20Guide.html#190351098">(Mar 12 2020 at 02:07)</a>:</h4>
<p>(This is not strictly necessary, but can be helpful, as rustfmt does diverge a little usually over time. I expect if you ask, <span class="user-mention" data-user-id="116009">@nikomatsakis</span> may have a emacs config to share, and there's probably some level of crowd sourcing for others :)</p>



<a name="190351157"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source%20formatting%20guidance%20in%20Rustc%20Dev%20Guide/near/190351157" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Chris Simpkins <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source.20formatting.20guidance.20in.20Rustc.20Dev.20Guide.html#190351157">(Mar 12 2020 at 02:08)</a>:</h4>
<p>This is great.  Thank you.  I'll try to update the documentation with this information.</p>



<a name="190351187"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source%20formatting%20guidance%20in%20Rustc%20Dev%20Guide/near/190351187" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source.20formatting.20guidance.20in.20Rustc.20Dev.20Guide.html#190351187">(Mar 12 2020 at 02:09)</a>:</h4>
<p>(FWIW, I had hoped that it was quite obvious what to do if CI failed, as it tells you to run x.py fmt, but it may be worth reading over the recent internals thread on this topic as well.)</p>



<a name="190351241"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source%20formatting%20guidance%20in%20Rustc%20Dev%20Guide/near/190351241" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source.20formatting.20guidance.20in.20Rustc.20Dev.20Guide.html#190351241">(Mar 12 2020 at 02:10)</a>:</h4>
<p>er, that sentence diverged a bit there :)</p>
<p>I meant that there seems to possibly be some confusion on this topic, so reading that internals thread may help guide what we should try to clarify in docs</p>



<a name="190351276"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source%20formatting%20guidance%20in%20Rustc%20Dev%20Guide/near/190351276" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Chris Simpkins <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source.20formatting.20guidance.20in.20Rustc.20Dev.20Guide.html#190351276">(Mar 12 2020 at 02:11)</a>:</h4>
<p>This didn't come up during a fmt fail on CI.  I wandered across this comment in the Guide and looked into whether it is possible to do line level fmt'ing</p>



<a name="190351335"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source%20formatting%20guidance%20in%20Rustc%20Dev%20Guide/near/190351335" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Chris Simpkins <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source.20formatting.20guidance.20in.20Rustc.20Dev.20Guide.html#190351335">(Mar 12 2020 at 02:13)</a>:</h4>
<p>This one? <a href="https://internals.rust-lang.org/t/forced-rustfmt-is-a-roadblock-to-contributing/11913" target="_blank" title="https://internals.rust-lang.org/t/forced-rustfmt-is-a-roadblock-to-contributing/11913">https://internals.rust-lang.org/t/forced-rustfmt-is-a-roadblock-to-contributing/11913</a></p>



<a name="190354312"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source%20formatting%20guidance%20in%20Rustc%20Dev%20Guide/near/190354312" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source.20formatting.20guidance.20in.20Rustc.20Dev.20Guide.html#190354312">(Mar 12 2020 at 03:38)</a>:</h4>
<p>yes that thread</p>



<a name="190354338"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source%20formatting%20guidance%20in%20Rustc%20Dev%20Guide/near/190354338" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source.20formatting.20guidance.20in.20Rustc.20Dev.20Guide.html#190354338">(Mar 12 2020 at 03:39)</a>:</h4>
<p>and i agree, there seems to be a lot of questions around this. perhaps after we update the chapter we can make a blog/internals post</p>



<a name="191379995"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source%20formatting%20guidance%20in%20Rustc%20Dev%20Guide/near/191379995" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Chris Simpkins <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source.20formatting.20guidance.20in.20Rustc.20Dev.20Guide.html#191379995">(Mar 22 2020 at 04:41)</a>:</h4>
<p>Collecting some of the feedback from <a href="https://internals.rust-lang.org/t/forced-rustfmt-is-a-roadblock-to-contributing/11913" target="_blank" title="https://internals.rust-lang.org/t/forced-rustfmt-is-a-roadblock-to-contributing/11913">the Internals thread</a>...</p>



<a name="191380043"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source%20formatting%20guidance%20in%20Rustc%20Dev%20Guide/near/191380043" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Chris Simpkins <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source.20formatting.20guidance.20in.20Rustc.20Dev.20Guide.html#191380043">(Mar 22 2020 at 04:42)</a>:</h4>
<p><a href="https://internals.rust-lang.org/t/forced-rustfmt-is-a-roadblock-to-contributing/11913/15" target="_blank" title="https://internals.rust-lang.org/t/forced-rustfmt-is-a-roadblock-to-contributing/11913/15">Source</a></p>
<blockquote>
<p>To stick another voice on it, you want <code>./x.py fmt</code>. This will use the pinned, in-tree version of rustfmt, which is both a) guaranteed to work (as CI is gated on it working) and b) won't disagree with <code>./x.py tidy</code>, like a local version of rustfmt might.</p>
<p>When working in the rustc tree, the current state is that you have to use <code>./x.py test</code> (which always runs tidy, even when narrowed) rather than cargo test. Even if you can/do get away with cargo-driven tests rather than bootstrap-driven tests, when in the rustc tree you should get into the habit of using <code>./x.py tidy</code>.</p>
</blockquote>



<a name="191380106"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source%20formatting%20guidance%20in%20Rustc%20Dev%20Guide/near/191380106" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Chris Simpkins <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source.20formatting.20guidance.20in.20Rustc.20Dev.20Guide.html#191380106">(Mar 22 2020 at 04:45)</a>:</h4>
<p><a href="https://internals.rust-lang.org/t/forced-rustfmt-is-a-roadblock-to-contributing/11913/16" target="_blank" title="https://internals.rust-lang.org/t/forced-rustfmt-is-a-roadblock-to-contributing/11913/16">Source</a></p>
<blockquote>
<p>Yes there are all sorts of ways to avoid forgetting to rustfmt before committing</p>
</blockquote>



<a name="191380161"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source%20formatting%20guidance%20in%20Rustc%20Dev%20Guide/near/191380161" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Chris Simpkins <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source.20formatting.20guidance.20in.20Rustc.20Dev.20Guide.html#191380161">(Mar 22 2020 at 04:47)</a>:</h4>
<p><a href="https://internals.rust-lang.org/t/forced-rustfmt-is-a-roadblock-to-contributing/11913/19" target="_blank" title="https://internals.rust-lang.org/t/forced-rustfmt-is-a-roadblock-to-contributing/11913/19">Source</a></p>
<blockquote>
<p>I also personally have rustfmt in my editor on every save, which makes me never forget formatting.</p>
<p>For now, I think we should strive to make <code>x.py fmt</code> more discoverable (or <code>x.py test --bless</code>). I would appreciate PRs improving any docs or error messages from folks who were lost in this thread.</p>
</blockquote>



<a name="191380301"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source%20formatting%20guidance%20in%20Rustc%20Dev%20Guide/near/191380301" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Chris Simpkins <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source.20formatting.20guidance.20in.20Rustc.20Dev.20Guide.html#191380301">(Mar 22 2020 at 04:51)</a>:</h4>
<p><a href="https://internals.rust-lang.org/t/forced-rustfmt-is-a-roadblock-to-contributing/11913/20" target="_blank" title="https://internals.rust-lang.org/t/forced-rustfmt-is-a-roadblock-to-contributing/11913/20">Source</a></p>
<p>Re: don't use <code>cargo +[toolchain] fmt</code>...</p>
<blockquote>
<p>either we should say directly using cargo isn't supported in the rustc tree and push people harder to use x.py, or we should say using cargo to test a single component is supported and push to make ./x.py test libfoo and cargo test -p foo execute the same tests (including tidy).</p>
</blockquote>



<a name="191380438"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source%20formatting%20guidance%20in%20Rustc%20Dev%20Guide/near/191380438" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Chris Simpkins <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source.20formatting.20guidance.20in.20Rustc.20Dev.20Guide.html#191380438">(Mar 22 2020 at 04:56)</a>:</h4>
<p><a href="https://internals.rust-lang.org/t/forced-rustfmt-is-a-roadblock-to-contributing/11913/30" target="_blank" title="https://internals.rust-lang.org/t/forced-rustfmt-is-a-roadblock-to-contributing/11913/30">Source</a></p>
<p>Re: the need for more prominent guidance on fmt approach</p>
<blockquote>
<p>I wasn't aware [x.py fmt] existed!</p>
</blockquote>



<a name="191380696"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source%20formatting%20guidance%20in%20Rustc%20Dev%20Guide/near/191380696" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Chris Simpkins <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source.20formatting.20guidance.20in.20Rustc.20Dev.20Guide.html#191380696">(Mar 22 2020 at 05:03)</a>:</h4>
<p><a href="https://internals.rust-lang.org/t/forced-rustfmt-is-a-roadblock-to-contributing/11913/49" target="_blank" title="https://internals.rust-lang.org/t/forced-rustfmt-is-a-roadblock-to-contributing/11913/49">Source</a></p>
<p>Re: definition of a contributor workflow with fmt'ing</p>
<blockquote>
<p>I think it would be useful to split out two threads from this discussion: rustfmt being too aggressive, perhaps, in formatting code, and improvements we can make in rust-lang/rust specifically to user's workflow. I personally would suspect that making the latter easier would be where we can most easily make the largest wins -- I'm open to suggestions and reviewing patches to the fmt integration if that would be helpful to folks.</p>
</blockquote>



<a name="191399467"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source%20formatting%20guidance%20in%20Rustc%20Dev%20Guide/near/191399467" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Chris Simpkins <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source.20formatting.20guidance.20in.20Rustc.20Dev.20Guide.html#191399467">(Mar 22 2020 at 14:41)</a>:</h4>
<p>Other reference material...</p>



<a name="191399521"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source%20formatting%20guidance%20in%20Rustc%20Dev%20Guide/near/191399521" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Chris Simpkins <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source.20formatting.20guidance.20in.20Rustc.20Dev.20Guide.html#191399521">(Mar 22 2020 at 14:42)</a>:</h4>
<p>This is the Rust code formatting RFC GitHub repository: <a href="https://github.com/rust-dev-tools/fmt-rfcs" target="_blank" title="https://github.com/rust-dev-tools/fmt-rfcs">https://github.com/rust-dev-tools/fmt-rfcs</a></p>



<a name="191399537"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source%20formatting%20guidance%20in%20Rustc%20Dev%20Guide/near/191399537" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Chris Simpkins <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source.20formatting.20guidance.20in.20Rustc.20Dev.20Guide.html#191399537">(Mar 22 2020 at 14:43)</a>:</h4>
<p>that describes a RFC based formatting approval process: <a href="https://github.com/rust-dev-tools/fmt-rfcs#the-formatting-rfc-process" target="_blank" title="https://github.com/rust-dev-tools/fmt-rfcs#the-formatting-rfc-process">https://github.com/rust-dev-tools/fmt-rfcs#the-formatting-rfc-process</a></p>



<a name="191399601"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source%20formatting%20guidance%20in%20Rustc%20Dev%20Guide/near/191399601" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Chris Simpkins <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source.20formatting.20guidance.20in.20Rustc.20Dev.20Guide.html#191399601">(Mar 22 2020 at 14:44)</a>:</h4>
<p>The Guide currently indicates:</p>
<blockquote>
<p>rustc is slowly moving towards the Rust standard coding style; at the moment, however, it follows a rather more chaotic style.</p>
</blockquote>
<p>where Rust standard coding style = style defined in the Rust code formatting RFC repository IIUC</p>



<a name="191399767"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source%20formatting%20guidance%20in%20Rustc%20Dev%20Guide/near/191399767" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Chris Simpkins <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source.20formatting.20guidance.20in.20Rustc.20Dev.20Guide.html#191399767">(Mar 22 2020 at 14:48)</a>:</h4>
<p>There is a "style team" that acts as the rustfmt RFC decision maker following a 2 wk open comment period called the Final Comment Period (FCP, announced on "This Week in Rust"):</p>
<blockquote>
<p>The style team will make the ultimate decision on accepting or closing a style issue. Decisions should be by consensus.</p>
</blockquote>
<p>Question: Is "style team" the rustfmt WG? (#wg-rustfmt on Discord)</p>



<a name="191400101"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source%20formatting%20guidance%20in%20Rustc%20Dev%20Guide/near/191400101" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Chris Simpkins <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source.20formatting.20guidance.20in.20Rustc.20Dev.20Guide.html#191400101">(Mar 22 2020 at 14:56)</a>:</h4>
<p>The fmt guiding principles are defined in <a href="https://github.com/rust-dev-tools/fmt-rfcs#guiding-principles" target="_blank" title="https://github.com/rust-dev-tools/fmt-rfcs#guiding-principles">https://github.com/rust-dev-tools/fmt-rfcs#guiding-principles</a> as:</p>
<blockquote>
<ul>
<li>readability</li>
<li>aesthetics</li>
<li>specifics</li>
<li>application</li>
</ul>
</blockquote>
<p>(decision thread is <a href="https://github.com/rust-dev-tools/fmt-rfcs/issues/4" target="_blank" title="https://github.com/rust-dev-tools/fmt-rfcs/issues/4">https://github.com/rust-dev-tools/fmt-rfcs/issues/4</a>)</p>



<a name="191400257"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source%20formatting%20guidance%20in%20Rustc%20Dev%20Guide/near/191400257" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Chris Simpkins <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source.20formatting.20guidance.20in.20Rustc.20Dev.20Guide.html#191400257">(Mar 22 2020 at 15:00)</a>:</h4>
<p>Notable comments in those principles from the compiler fmt PoV:</p>
<blockquote>
<ul>
<li>readability of code when quoted in rustc error messages</li>
<li>compatibility with version control practices - preserving diffs, merge-friendliness, etc.</li>
<li>ease of implementation (in Rustfmt, and in other tools/editors/code generators)</li>
<li>internal consistency</li>
</ul>
</blockquote>



<a name="191402445"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source%20formatting%20guidance%20in%20Rustc%20Dev%20Guide/near/191402445" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Chris Simpkins <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source.20formatting.20guidance.20in.20Rustc.20Dev.20Guide.html#191402445">(Mar 22 2020 at 15:49)</a>:</h4>
<p>Question: Are there different (subset, superset, different set) principles required, or different priority levels for those defined, for compiler source code base fmt’ing? </p>
<p>Enter <code>x.py fmt</code> and <code>tidy</code>...</p>



<a name="191403431"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source%20formatting%20guidance%20in%20Rustc%20Dev%20Guide/near/191403431" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Chris Simpkins <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source.20formatting.20guidance.20in.20Rustc.20Dev.20Guide.html#191403431">(Mar 22 2020 at 16:14)</a>:</h4>
<p>The Guide indicates the following about tidy:</p>
<blockquote>
<p>We do have some mandatory formatting conventions, which are automatically enforced by a script we affectionately call the "tidy" script. The tidy script runs automatically when you do ./x.py test and can be run in isolation with ./x.py test tidy.</p>
</blockquote>
<p>Question: Re: the "mandatory formatting conventions" statement,  are the conventions listed in <a href="https://rustc-dev-guide.rust-lang.org/conventions.html?highlight=tidy#formatting-and-the-tidy-script" target="_blank" title="https://rustc-dev-guide.rust-lang.org/conventions.html?highlight=tidy#formatting-and-the-tidy-script">https://rustc-dev-guide.rust-lang.org/conventions.html?highlight=tidy#formatting-and-the-tidy-script</a> current and comprehensive guidance on what tidy enforces for compiler contributors?</p>



<a name="191403529"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source%20formatting%20guidance%20in%20Rustc%20Dev%20Guide/near/191403529" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Chris Simpkins <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source.20formatting.20guidance.20in.20Rustc.20Dev.20Guide.html#191403529">(Mar 22 2020 at 16:17)</a>:</h4>
<p>tidy entry point: <a href="https://github.com/rust-lang/rust/blob/master/src/tools/tidy/src/main.rs" target="_blank" title="https://github.com/rust-lang/rust/blob/master/src/tools/tidy/src/main.rs">https://github.com/rust-lang/rust/blob/master/src/tools/tidy/src/main.rs</a><br>
rust code base style checks are defined in: <a href="https://github.com/rust-lang/rust/blob/master/src/tools/tidy/src/style.rs" target="_blank" title="https://github.com/rust-lang/rust/blob/master/src/tools/tidy/src/style.rs">https://github.com/rust-lang/rust/blob/master/src/tools/tidy/src/style.rs</a></p>



<a name="191404977"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source%20formatting%20guidance%20in%20Rustc%20Dev%20Guide/near/191404977" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Chris Simpkins <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source.20formatting.20guidance.20in.20Rustc.20Dev.20Guide.html#191404977">(Mar 22 2020 at 16:51)</a>:</h4>
<p><strong>Tidy style definitions</strong></p>
<ul>
<li>style checks are only performed on files with the extensions: ".rs", ".py", ".js", ".sh", ".c", ".cpp", ".h", ".md"(<a href="https://github.com/rust-lang/rust/blob/5ae85f43f4eeaf177cd12f47958b7ff62786b612/src/tools/tidy/src/style.rs#L143-L146" target="_blank" title="https://github.com/rust-lang/rust/blob/5ae85f43f4eeaf177cd12f47958b7ff62786b612/src/tools/tidy/src/style.rs#L143-L146">src</a>)</li>
<li>MD file checks are only for long error code files (<a href="https://github.com/rust-lang/rust/blob/5ae85f43f4eeaf177cd12f47958b7ff62786b612/src/tools/tidy/src/style.rs#L160-L161" target="_blank" title="https://github.com/rust-lang/rust/blob/5ae85f43f4eeaf177cd12f47958b7ff62786b612/src/tools/tidy/src/style.rs#L160-L161">src</a>)</li>
</ul>
<p><strong> Style Errors</strong></p>
<ul>
<li>file content is empty (<a href="https://github.com/rust-lang/rust/blob/5ae85f43f4eeaf177cd12f47958b7ff62786b612/src/tools/tidy/src/style.rs#L165-L167" target="_blank" title="https://github.com/rust-lang/rust/blob/5ae85f43f4eeaf177cd12f47958b7ff62786b612/src/tools/tidy/src/style.rs#L165-L167">src</a>)</li>
<li>max columns = 80 for error code <code>.rs</code> files and all Markdown files, max columns = 100 for all other checked file types - exception: long URL (<a href="https://github.com/rust-lang/rust/blob/5ae85f43f4eeaf177cd12f47958b7ff62786b612/src/tools/tidy/src/style.rs#L169-L173" target="_blank" title="https://github.com/rust-lang/rust/blob/5ae85f43f4eeaf177cd12f47958b7ff62786b612/src/tools/tidy/src/style.rs#L169-L173">src</a>)</li>
<li>line contains tab character(s) (<a href="https://github.com/rust-lang/rust/blob/5ae85f43f4eeaf177cd12f47958b7ff62786b612/src/tools/tidy/src/style.rs#L206" target="_blank" title="https://github.com/rust-lang/rust/blob/5ae85f43f4eeaf177cd12f47958b7ff62786b612/src/tools/tidy/src/style.rs#L206">src</a>)</li>
<li>line ends with whitespace (<a href="https://github.com/rust-lang/rust/blob/5ae85f43f4eeaf177cd12f47958b7ff62786b612/src/tools/tidy/src/style.rs#L209" target="_blank" title="https://github.com/rust-lang/rust/blob/5ae85f43f4eeaf177cd12f47958b7ff62786b612/src/tools/tidy/src/style.rs#L209">src</a>)</li>
<li>line contains CR character (<a href="https://github.com/rust-lang/rust/blob/5ae85f43f4eeaf177cd12f47958b7ff62786b612/src/tools/tidy/src/style.rs#L212" target="_blank" title="https://github.com/rust-lang/rust/blob/5ae85f43f4eeaf177cd12f47958b7ff62786b612/src/tools/tidy/src/style.rs#L212">src</a>)</li>
<li>line contains the string "TODO" (<a href="https://github.com/rust-lang/rust/blob/5ae85f43f4eeaf177cd12f47958b7ff62786b612/src/tools/tidy/src/style.rs#L216" target="_blank" title="https://github.com/rust-lang/rust/blob/5ae85f43f4eeaf177cd12f47958b7ff62786b612/src/tools/tidy/src/style.rs#L216">src</a>)</li>
<li>line contains the string "//" and contains "XXX" (<a href="https://github.com/rust-lang/rust/blob/5ae85f43f4eeaf177cd12f47958b7ff62786b612/src/tools/tidy/src/style.rs#L219" target="_blank" title="https://github.com/rust-lang/rust/blob/5ae85f43f4eeaf177cd12f47958b7ff62786b612/src/tools/tidy/src/style.rs#L219">src</a>)</li>
<li>file contains a copyright statement with copyright holder "Rust Developers" or "Rust Project Developers" (<a href="https://github.com/rust-lang/rust/blob/5ae85f43f4eeaf177cd12f47958b7ff62786b612/src/tools/tidy/src/style.rs#L237-L241" target="_blank" title="https://github.com/rust-lang/rust/blob/5ae85f43f4eeaf177cd12f47958b7ff62786b612/src/tools/tidy/src/style.rs#L237-L241">src</a>)</li>
<li>line has unexplained doctest info ignore (<a href="https://github.com/rust-lang/rust/blob/5ae85f43f4eeaf177cd12f47958b7ff62786b612/src/tools/tidy/src/style.rs#L248" target="_blank" title="https://github.com/rust-lang/rust/blob/5ae85f43f4eeaf177cd12f47958b7ff62786b612/src/tools/tidy/src/style.rs#L248">src</a>)</li>
<li>file has a leading newline (<a href="https://github.com/rust-lang/rust/blob/5ae85f43f4eeaf177cd12f47958b7ff62786b612/src/tools/tidy/src/style.rs#L254-L265" target="_blank" title="https://github.com/rust-lang/rust/blob/5ae85f43f4eeaf177cd12f47958b7ff62786b612/src/tools/tidy/src/style.rs#L254-L265">src</a>)</li>
<li>file does not have a trailing newline (<a href="https://github.com/rust-lang/rust/blob/5ae85f43f4eeaf177cd12f47958b7ff62786b612/src/tools/tidy/src/style.rs#L271" target="_blank" title="https://github.com/rust-lang/rust/blob/5ae85f43f4eeaf177cd12f47958b7ff62786b612/src/tools/tidy/src/style.rs#L271">src</a>)</li>
<li>file has more than one trailing newline (<a href="https://github.com/rust-lang/rust/blob/5ae85f43f4eeaf177cd12f47958b7ff62786b612/src/tools/tidy/src/style.rs#L273" target="_blank" title="https://github.com/rust-lang/rust/blob/5ae85f43f4eeaf177cd12f47958b7ff62786b612/src/tools/tidy/src/style.rs#L273">src</a>)</li>
<li>file length &gt; 3000 lines (<a href="https://github.com/rust-lang/rust/blob/5ae85f43f4eeaf177cd12f47958b7ff62786b612/src/tools/tidy/src/style.rs#L279-L290" target="_blank" title="https://github.com/rust-lang/rust/blob/5ae85f43f4eeaf177cd12f47958b7ff62786b612/src/tools/tidy/src/style.rs#L279-L290">src</a>)</li>
<li><code>*.cpp</code> <em>only</em>: line contains string "llvm_unreachable" (<a href="https://github.com/rust-lang/rust/blob/5ae85f43f4eeaf177cd12f47958b7ff62786b612/src/tools/tidy/src/style.rs#L251" target="_blank" title="https://github.com/rust-lang/rust/blob/5ae85f43f4eeaf177cd12f47958b7ff62786b612/src/tools/tidy/src/style.rs#L251">src</a>)</li>
<li><code>libcore</code> <em>only</em>: line contains "unsafe" and is not a comment (<a href="https://github.com/rust-lang/rust/blob/5ae85f43f4eeaf177cd12f47958b7ff62786b612/src/tools/tidy/src/style.rs#L225" target="_blank" title="https://github.com/rust-lang/rust/blob/5ae85f43f4eeaf177cd12f47958b7ff62786b612/src/tools/tidy/src/style.rs#L225">src</a>)</li>
</ul>
<p><strong>Tidy opt out</strong></p>
<ul>
<li>it is possible to opt out of checks with an <code>ignore-tidy-*</code> directive (<a href="https://github.com/rust-lang/rust/blob/5ae85f43f4eeaf177cd12f47958b7ff62786b612/src/tools/tidy/src/style.rs#L115-L127" target="_blank" title="https://github.com/rust-lang/rust/blob/5ae85f43f4eeaf177cd12f47958b7ff62786b612/src/tools/tidy/src/style.rs#L115-L127">src</a>)</li>
</ul>



<a name="191405461"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source%20formatting%20guidance%20in%20Rustc%20Dev%20Guide/near/191405461" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Chris Simpkins <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source.20formatting.20guidance.20in.20Rustc.20Dev.20Guide.html#191405461">(Mar 22 2020 at 17:02)</a>:</h4>
<div class="codehilite"><pre><span></span><span class="sd">//! Note that some of these rules are excluded from Rust files because we enforce rustfmt. It is</span>
<span class="sd">//! preferable to be formatted rather than tidy-clean.</span>
</pre></div>


<p>(<a href="https://github.com/rust-lang/rust/blob/5ae85f43f4eeaf177cd12f47958b7ff62786b612/src/tools/tidy/src/style.rs#L13-L14" target="_blank" title="https://github.com/rust-lang/rust/blob/5ae85f43f4eeaf177cd12f47958b7ff62786b612/src/tools/tidy/src/style.rs#L13-L14">src</a>)</p>



<a name="191420205"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source%20formatting%20guidance%20in%20Rustc%20Dev%20Guide/near/191420205" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source.20formatting.20guidance.20in.20Rustc.20Dev.20Guide.html#191420205">(Mar 22 2020 at 22:43)</a>:</h4>
<p><span class="user-mention" data-user-id="262810">@Chris Simpkins</span> Wow, thanks for doing all that research</p>



<a name="191420464"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source%20formatting%20guidance%20in%20Rustc%20Dev%20Guide/near/191420464" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source.20formatting.20guidance.20in.20Rustc.20Dev.20Guide.html#191420464">(Mar 22 2020 at 22:49)</a>:</h4>
<blockquote>
<p>Question: Is "style team" the rustfmt WG? (#wg-rustfmt on Discord)</p>
</blockquote>
<p>Tbh, I didn't know this was a distinct team. Perhaps <span class="user-mention" data-user-id="116122">@simulacrum</span> knows?</p>
<blockquote>
<p>Question: Are there different (subset, superset, different set) principles required, or different priority levels for those defined, for compiler source code base fmt’ing? </p>
</blockquote>
<p>AFAICT, it varies from one compiler hacker to another what they value the most. Personally for me, readability and consistency across the (very large) codebase are the most important, but others may prioritize other things, I guess.</p>
<blockquote>
<p>Question: Re: the "mandatory formatting conventions" statement, are the conventions listed in <a href="https://rustc-dev-guide.rust-lang.org/conventions.html?highlight=tidy#formatting-and-the-tidy-script" target="_blank" title="https://rustc-dev-guide.rust-lang.org/conventions.html?highlight=tidy#formatting-and-the-tidy-script">https://rustc-dev-guide.rust-lang.org/conventions.html?highlight=tidy#formatting-and-the-tidy-script</a> current and comprehensive guidance on what tidy enforces for compiler contributors?</p>
</blockquote>
<p>I don't think we document them anywhere. But generally, we use nightly <code>rustfmt</code> + <a href="https://github.com/rust-lang/rust/blob/master/rustfmt.toml" target="_blank" title="https://github.com/rust-lang/rust/blob/master/rustfmt.toml">this <code>rustfmt.toml</code></a>. I don't personally know how important it is to document the specific things. I just run <code>./x.py fmt</code> before committing and don't really think about it again. Do you feel that it is an obstacle to new developers?</p>



<a name="191420524"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source%20formatting%20guidance%20in%20Rustc%20Dev%20Guide/near/191420524" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source.20formatting.20guidance.20in.20Rustc.20Dev.20Guide.html#191420524">(Mar 22 2020 at 22:50)</a>:</h4>
<p>It is no longer an active team, to my knowledge - used to be a WG (under, IIRC,  @nrc).</p>



<a name="191420538"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source%20formatting%20guidance%20in%20Rustc%20Dev%20Guide/near/191420538" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source.20formatting.20guidance.20in.20Rustc.20Dev.20Guide.html#191420538">(Mar 22 2020 at 22:51)</a>:</h4>
<p>We basically only support x.py fmt (and you can do what it does yourself, e.g. on save).</p>



<a name="191420609"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source%20formatting%20guidance%20in%20Rustc%20Dev%20Guide/near/191420609" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Chris Simpkins <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source.20formatting.20guidance.20in.20Rustc.20Dev.20Guide.html#191420609">(Mar 22 2020 at 22:53)</a>:</h4>
<blockquote>
<p>I don't think we document them anywhere. But generally, we use nightly rustfmt + this rustfmt.toml. I don't personally know how important it is to document the specific things. I just run ./x.py fmt before committing and don't really think about it again. Do you feel that it is an obstacle to new developers?</p>
</blockquote>
<p>Not necessarily an obstacle, but the Internals thread points to a good deal of questioning about why it is necessary at all.  I wonder if helps to address <em>why</em> the formatting is used <strong>and</strong> how to easily accomplish it. There were active (IIUC reasonably long-term contributrors to rust) developers in the Internals thread who knew nothing of the ./x.py formatting approaches.  The arguments veered off into why make developers do it at all, just do it after they push land.  Maybe we try to address these things?</p>



<a name="191420696"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source%20formatting%20guidance%20in%20Rustc%20Dev%20Guide/near/191420696" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source.20formatting.20guidance.20in.20Rustc.20Dev.20Guide.html#191420696">(Mar 22 2020 at 22:54)</a>:</h4>
<p>Hmm... fair point</p>



<a name="191420711"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source%20formatting%20guidance%20in%20Rustc%20Dev%20Guide/near/191420711" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source.20formatting.20guidance.20in.20Rustc.20Dev.20Guide.html#191420711">(Mar 22 2020 at 22:55)</a>:</h4>
<p>Personally, I would rather get a statement on this from t-compiler or something</p>



<a name="191420775"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source%20formatting%20guidance%20in%20Rustc%20Dev%20Guide/near/191420775" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source.20formatting.20guidance.20in.20Rustc.20Dev.20Guide.html#191420775">(Mar 22 2020 at 22:56)</a>:</h4>
<p>That is, since it does appear to have a fair amount of controversy I would rather get guidance from project leaders on this topic</p>



<a name="191420788"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source%20formatting%20guidance%20in%20Rustc%20Dev%20Guide/near/191420788" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source.20formatting.20guidance.20in.20Rustc.20Dev.20Guide.html#191420788">(Mar 22 2020 at 22:57)</a>:</h4>
<p>I think you are right that it would be good to address in the guide at some point though</p>



<a name="191420887"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source%20formatting%20guidance%20in%20Rustc%20Dev%20Guide/near/191420887" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Chris Simpkins <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source.20formatting.20guidance.20in.20Rustc.20Dev.20Guide.html#191420887">(Mar 22 2020 at 22:59)</a>:</h4>
<p><span class="user-mention silent" data-user-id="198054">mark-i-m</span> <a href="#narrow/stream/196385-t-compiler.2Fwg-learning/topic/Source.20formatting.20guidance.20in.20Rustc.20Dev.20Guide/near/191420775" title="#narrow/stream/196385-t-compiler.2Fwg-learning/topic/Source.20formatting.20guidance.20in.20Rustc.20Dev.20Guide/near/191420775">said</a>:</p>
<blockquote>
<p>That is, since it does appear to have a fair amount of controversy I would rather get guidance from project leaders on this topic</p>
</blockquote>
<p>Definitely makes sense.  I would be happy to pull together documentation for the Guide and/or a blog post on the topic once we understand if/how documentation might help to address concerns expressed there.   There is more to it than docs, but we may be able to help.</p>



<a name="191421691"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source%20formatting%20guidance%20in%20Rustc%20Dev%20Guide/near/191421691" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Chris Simpkins <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source.20formatting.20guidance.20in.20Rustc.20Dev.20Guide.html#191421691">(Mar 22 2020 at 23:19)</a>:</h4>
<p><span class="user-mention" data-user-id="116122">@simulacrum</span> </p>
<blockquote>
<p>We basically only support x.py fmt (and you can do what it does yourself, e.g. on save).</p>
</blockquote>
<p>And the recommended approach as I understand it, is to run <code>./x.py test -i --stage 1 [file | dir]</code> before committing.  This runs tidy so that you get the tidy lints and know that you need to fmt if you don't use a fmt on save approach.</p>



<a name="191421814"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source%20formatting%20guidance%20in%20Rustc%20Dev%20Guide/near/191421814" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source.20formatting.20guidance.20in.20Rustc.20Dev.20Guide.html#191421814">(Mar 22 2020 at 23:23)</a>:</h4>
<p>No, that's not generally how to get formatting. I would recommend just x.py fmt before committing if you don't have it set up on save.</p>



<a name="191421859"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source%20formatting%20guidance%20in%20Rustc%20Dev%20Guide/near/191421859" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source.20formatting.20guidance.20in.20Rustc.20Dev.20Guide.html#191421859">(Mar 22 2020 at 23:24)</a>:</h4>
<p>(That is the right approach for testing, though)</p>



<a name="191421884"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source%20formatting%20guidance%20in%20Rustc%20Dev%20Guide/near/191421884" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Chris Simpkins <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source.20formatting.20guidance.20in.20Rustc.20Dev.20Guide.html#191421884">(Mar 22 2020 at 23:25)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116122">simulacrum</span> <a href="#narrow/stream/196385-t-compiler.2Fwg-learning/topic/Source.20formatting.20guidance.20in.20Rustc.20Dev.20Guide/near/191421814" title="#narrow/stream/196385-t-compiler.2Fwg-learning/topic/Source.20formatting.20guidance.20in.20Rustc.20Dev.20Guide/near/191421814">said</a>:</p>
<blockquote>
<p>No, that's not generally how to get formatting. I would recommend just x.py fmt before committing if you don't have it set up on save.</p>
</blockquote>
<p>Sorry, I wasn't clear.  That lints the files IIUC and tidy informs you as part of the local test run that you need to fmt correct?  The Internals thread suggests that there are those who are surprised to find that (1) they didn't fmt; (2) their CI build fails minutes later and they don't know pass/fail status of build for their changes because the lack of fmt blocked completion of the build.  Local .x.py test run does run tidy?</p>



<a name="191428970"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source%20formatting%20guidance%20in%20Rustc%20Dev%20Guide/near/191428970" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source.20formatting.20guidance.20in.20Rustc.20Dev.20Guide.html#191428970">(Mar 23 2020 at 03:02)</a>:</h4>
<p><span class="user-mention" data-user-id="262810">@Chris Simpkins</span> there is also <code>./x.py fmt --check</code> which is run by <code>./x.py test ...</code></p>



<a name="191474260"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source%20formatting%20guidance%20in%20Rustc%20Dev%20Guide/near/191474260" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/196385-t-compiler/wg-rustc-dev-guide/topic/Source.20formatting.20guidance.20in.20Rustc.20Dev.20Guide.html#191474260">(Mar 23 2020 at 13:44)</a>:</h4>
<p>x.py test does run tidy, but generally speaking most people should not be running x.py test locally (it's long). I would personally recommend that most people just run UI tests after a compiler change, if that</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>